import xlwt

data_json={
  "1":["小花",99,100,98.5],
  "2":["小王",90,30.5,95],
  "3":["小明",67.5,49.6,88]
}
title = ["编号","姓名","语文成绩","数学成绩","英语成绩","平均分","总分"]

#1、循环一下，把字典的key插入到字典的value里面，同时计算平均分、总分
all_data = []
for k,v in data_json.items():
  sum_score = round(sum(v[1:]),2)
  avg_score = round(sum_score / len(v[1:]),2)
  v.insert(0,k) #学号放在最前面
  v.append(sum_score)
  v.append(avg_score)
  all_data.append(v)
all_data.insert(0,title)

book = xlwt.Workbook()
sheet = book.add_sheet("sheet")

for row,i in enumerate(all_data): #[(0,[1,2,3,4]),(1, [4,5,6,10])]
    for col,j in enumerate(i): #[(0,1),(1, 2),(2, 3),(3, 4),(4, 4), (5,5),(6, 6),(7,10)]
        sheet.write(row,col,j)

book.save("data.xls")